package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.mapper.StudentManageMapper;
import com.ruoyi.system.pojo.domain.StudentManage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.FocusMapper;
import com.ruoyi.system.pojo.domain.Focus;
import com.ruoyi.system.service.IFocusService;

/**
 * 重点关注Service业务层处理
 * 
 * @author sxb
 * @date 2024-01-22
 */
@Service
public class FocusServiceImpl implements IFocusService 
{
    @Autowired
    private FocusMapper focusMapper;
    @Autowired
    private StudentManageMapper studentManageMapper;

    /**
     * 查询重点关注
     * 
     * @param id 重点关注主键
     * @return 重点关注
     */
    @Override
    public Focus selectFocusById(Long id)
    {
        return focusMapper.selectFocusById(id);
    }

    /**
     * 查询重点关注列表
     * 
     * @param focus 重点关注
     * @return 重点关注
     */
    @Override
    public List<Focus> selectFocusList(Focus focus)
    {
        return focusMapper.selectFocusList(focus);
    }

    /**
     * 新增重点关注
     * 
     * @param focus 重点关注
     * @return 结果
     */
    @Override
    public int insertFocus(Focus focus)
    {
        //要将重点关注的ID设置成查询出来的学生的ID，因为重点关注了学生之间的是一对一的关系
        //查询出当前学生的管理信息 获取学生的ID 设置成focus中的id
        StudentManage studentManage = studentManageMapper.selectStudentManageById(focus.getStudentId());
        //设置重点关注中的id 为当前指定学生的id
        focus.setStudentId(studentManage.getId());
        focus.setId(studentManage.getId());
        focus.setClassId(studentManage.getClassId());
        focus.setStudentName(studentManage.getStudentName());
        return focusMapper.insertFocus(focus);
    }

    /**
     * 修改重点关注
     * 
     * @param focus 重点关注
     * @return 结果
     */
    @Override
    public int updateFocus(Focus focus)
    {
        return focusMapper.updateFocus(focus);
    }

    /**
     * 批量删除重点关注
     * 
     * @param ids 需要删除的重点关注主键
     * @return 结果
     */
    @Override
    public int deleteFocusByIds(Long[] ids)
    {
        return focusMapper.deleteFocusByIds(ids);
    }

    /**
     * 删除重点关注信息
     * 
     * @param id 重点关注主键
     * @return 结果
     */
    @Override
    public int deleteFocusById(Long id)
    {
        return focusMapper.deleteFocusById(id);
    }
}
